package com.guojiang.guoaicodemother.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

/**
 * 用户角色枚举
 */
@Getter
public enum UserRoleEnum {

    USER("用户", "user"),
    ADMIN("管理员", "admin"),
    VIP("会员","vip"),
    SVIP("超级会员","svip");

    private final String text;

    private final String value;

    UserRoleEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据枚举 value 获取枚举
     *
     * @param value
     * @return
     */
    public static UserRoleEnum getEnumByValue(String value) {
        if (ObjUtil.isEmpty(value) || ObjUtil.isNull(value)) return null;
        for (UserRoleEnum currEnum : UserRoleEnum.values()) {
            if (value.equals(currEnum.value)) return currEnum;
        }
        return null;
    }
}
